
package petrivis.view;

import java.awt.BasicStroke;
import java.awt.Font;
import petrivis.model.PetriNet;
import prefuse.Constants;
import prefuse.action.assignment.ColorAction;
import prefuse.action.assignment.DataColorAction;
import prefuse.action.assignment.FontAction;
import prefuse.action.assignment.ShapeAction;
import prefuse.action.assignment.StrokeAction;
import prefuse.util.ColorLib;
import prefuse.visual.VisualItem;

/**
 * Action List with the actions to color the Petri Net elements
 * @author Jorge Munoz
 */
public class PNColorActionList extends ActionListWithActions{

    @Override
    protected void initActions() {

        //TODO Color getted by properties file
        //TODO Array with all the colors and constants to translate a name
        //to the array possition

        //Fill Node Action
        int pFillColor = ColorLib.rgb(255,255,255);
        int tFillColor = ColorLib.rgb(255,255,255);
        int fillNPalette[] = {pFillColor,tFillColor};
        DataColorAction fillN = new DataColorAction
               (PNVisualization.NODES,
                PetriNet.PLACE_COL,
                Constants.NOMINAL,
                VisualItem.FILLCOLOR,
                fillNPalette);
        add(fillN);

        //Fill Edge Action
        int aFillColor = ColorLib.rgb(100,100,100);
        ColorAction fillE = new ColorAction
                (PNVisualization.EDGES, VisualItem.FILLCOLOR, aFillColor);
        add(fillE);

        //Fill Token Action
        int tokFillColor = ColorLib.rgb(000,000,000);
        ColorAction fillTok = new ColorAction
                (PNVisualization.TOKENS, VisualItem.FILLCOLOR, tokFillColor);
        add(fillTok);


        
        //Stroke Node Action
        int pStrokeColor = ColorLib.rgb(100,100,100);
        int tStrokeColor = ColorLib.rgb(100,100,100);
        int strokeNPalette[] = {pStrokeColor,tStrokeColor};
        DataColorAction strokeN = new DataColorAction
               (PNVisualization.NODES,
                PetriNet.PLACE_COL,
                Constants.NOMINAL,
                VisualItem.STROKECOLOR,
                strokeNPalette);
        add(strokeN);

        //Stroke Edge Action
        int aStrokeColor = ColorLib.rgb(100,100,100);
        ColorAction strokeE = new ColorAction
                (PNVisualization.EDGES, VisualItem.STROKECOLOR, aStrokeColor);
        add(strokeE);

        //Stroke Token Action
        /*int tokStrokeColor = ColorLib.rgb(000, 000, 000);
        ColorAction strokeTok = new ColorAction
                (PNVisualization.TOKEN1, VisualItem.STROKECOLOR, tokStrokeColor);
        add(strokeTok);*/

        //Text Transition Actions
        int tTextColor = ColorLib.rgb(0, 0, 225);
        ColorAction textT = new ColorAction(PNVisualization.NODES,
                PNVisualization.transPred,VisualItem.TEXTCOLOR,tTextColor);
        add(textT);

        //Text Tokens Num Color Action
        int tokNumTextColor = ColorLib.rgb(255, 0, 0);
        ColorAction textTokNum = new ColorAction
                (PNVisualization.TOKENS, VisualItem.TEXTCOLOR, tokNumTextColor);
        add(textTokNum);
        
        //Text Tokens Num Font Action
        Font tokNumTextFont = new Font(null,Font.BOLD,25);
        FontAction fontTokNum = new FontAction
                (PNVisualization.TOKENS, tokNumTextFont);
        add(fontTokNum);

        //Text Weight Action
        int weightTextColor = ColorLib.rgb(000, 000, 000);
        ColorAction textW = new ColorAction
                (PNVisualization.WEIGHTS, VisualItem.TEXTCOLOR, weightTextColor);
        add(textW);


        //Stroke Node Size Action
        int strokeNSize = 2;
        add(new StrokeAction(PNVisualization.NODES,new BasicStroke(strokeNSize)));

        //Shape Place Action
        add(new ShapeAction(PNVisualization.NODES, Constants.SHAPE_ELLIPSE));

    }

}
